<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        border: solid;
        padding: 10px;
        margin: 10px;
      }
    </style>
  </head>
  <body>
    <div id="box1">
      box1
      <div id="box2">
        box2
        <div id="box3">
          box3
          <div id="box4">box4</div>
        </div>
      </div>
    </div>
    <script>
      document.getElementById("box1").addEventListener(
        "click",
        function () {
          console.log("1");
        },
        { capture: true }
      );
      document.getElementById("box2").addEventListener(
        "click",
        function () {
          console.log("2");
        },
        { capture: true }
      );

      document.getElementById("box3").addEventListener(
        "click",
        function () {
          console.log("3");
        },
        { capture: true }
      );

      document.getElementById("box4").addEventListener(
        "click",
        function () {
          console.log("4");
        },
        { capture: true }
      );

      document.getElementById("box4").addEventListener("click", function () {
        console.log("4");
      });
      document.getElementById("box3").addEventListener("click", function () {
        console.log("3");
      });
      document.getElementById("box2").addEventListener("click", function () {
        console.log("2");
      });
      document.getElementById("box1").addEventListener("click", function () {
        console.log("1");
      });
    </script>
  </body>
</html>
